$(function(){
// 发送请求，获取数据
function sendRequest(){
    // let $options = {
    //      data : {
                pagesize : 30
            // }
    //  }
    return $.ajax("http://localhost:8888/goods/list?pagesize=30");

}

// 渲染页面
function renderPage(data){
    let { list } = data;
    $(".goods").html(
        list.map( (item) => {
            return `<li class="goods-container" data-id=${item.goods_id}>
                <img class="lazyload" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.huabanimg.com%2F2e875b78e4979cf750ff082b1b7561879f1e8ac377f4-hEUmN7_fw658&refer=http%3A%2F%2Fhbimg.huabanimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1668865613&t=c5c2e5c902dd89057288085fe6eca1c9" 
                data-src="${item.img_big_logo}" alt="">
                <h3>${item.title}</h3>
                <h2>${item.price}</h2>
            </li> `
        })
    )
    lazyload()
}


sendRequest().done(renderPage);

// 跳转详情页
function jumpDetailPage(){
    location.href = "detail.html#" + $(this).attr("data-id");
}

$(".goods").on("click",".goods-container",jumpDetailPage);


















})